package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

public class JDBCDemo12 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入用户名：");
        String username = scanner.nextLine();
        try(Connection connection = DBUtil.getConnection()){
            String sql = "DELETE FROM userinfo WHERE username=? ";
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,username);
            int count = preparedStatement.executeUpdate();
            System.out.println(count>0?"修改成功":"修改失败");
    }catch(SQLException e){
            e.printStackTrace();}
}
}
